package com.xinghen.ace.auth.common.jwt.impl;

import com.xinghen.ace.auth.common.jwt.IJWTInfo;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

/**
 * @author xinghen
 * @ClassName: JWTInfo
 * @Package: com.xinghen.ace.auth.common.jwt.impl
 * @Description TODO
 * @create 2018-05-04 15:07
 */
@Data
@AllArgsConstructor
public class JWTInfo implements IJWTInfo, Serializable {

    private static final Long serialVersionUID = 12312312312321L;

    private String username;

    private String userId;

    private String name;

    @Override
    public String getUniqueName() {
        return username;
    }

    @Override
    public String getId() {
        return userId;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        JWTInfo jwtInfo = (JWTInfo) o;
        return (username != null ? username.equals(jwtInfo.username) :
                jwtInfo.username == null) && (userId != null ? userId.equals(jwtInfo.userId) :
                jwtInfo.userId == null);

    }

    @Override
    public int hashCode() {
        int result = username != null ? username.hashCode() : 0;
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        return result;
    }
}
